package com.usian.wemedia.controller;

import com.usian.apis.wemedia.WmnewsControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmNewsDto;
import com.usian.model.media.dtos.WmNewsPageReqDto;
import com.usian.model.media.pojos.WmNews;
import com.usian.wemedia.service.WmnewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/wmnews")
public class WmnewsController implements WmnewsControllerApi {
    @Autowired
    WmnewsService wmnewsService;
    @Override
    @PostMapping("/findList")
    public ResponseResult wmnewsList(@RequestBody WmNewsPageReqDto dto) {
        return wmnewsService.findWmnewsList(dto);
    }

    @Override
    @PostMapping("/submitNews")
    public ResponseResult submitNews(@RequestBody WmNewsDto wmNews) {
        return wmnewsService.submitNews(wmNews);
    }
    @Override
    @GetMapping("/findById/{id}")
    public WmNews findById(@PathVariable Integer id) {
        return wmnewsService.findById(id);
    }

    @Override
    @GetMapping("/delById")
    public ResponseResult delById(Integer id) {
        return wmnewsService.delById(id);
    }

    @Override
    @PostMapping("/editEnable")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto) {
        return wmnewsService.downOrUp(dto);
    }

    @Override
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmNews wmNews) {
        return wmnewsService.update(wmNews);
    }
    @Override
    @GetMapping("/getIds")
    public List<Integer> getIds(){
        return wmnewsService.getIds();
    }
}
